package com.guo.mysetvletlistener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class MyServletContextListener implements ServletContextListener {

	private ServletContext context = null;
	
	//  该方法在 ServletContext启动后调用
	@Override
	public void contextDestroyed(ServletContextEvent event) {
		this.context = null;
	}
	// 该方法在 ServletContext 销毁时调用
	@Override
	public void contextInitialized(ServletContextEvent event) {
		context = event.getServletContext();
		this.context.setAttribute("myObject", "添加了自定义的对象");
	
	}

}
